﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.DirectoryServices;
using System.Web.Mail;
using System.Text;
using WdpaLoginServiceRef;

public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        if (User.Identity.IsAuthenticated)
        {
            Response.Redirect("default.aspx");
        }

        string strMigrateUser = Convert.ToString(Session["MigrateUser"]);

        if (strMigrateUser == "true")
        {
            divChangePassword.Visible = true;
        }
        else
        {
            Response.Redirect("default.aspx");
        }

        divAccountNotActivated.Visible = false;
        divSuccessPasswordChange.Visible = false;
    }



    protected void btnUpdatePassword_Click(object sender, EventArgs e)
    {
        string strUsrEmail = Convert.ToString(Session["usrEmail"]);

        WdpaLoginService WdpaLoginService1 = new WdpaLoginService();

        WdpaLoginService1.UpdatePassword(strUsrEmail, tbNewPassword1.Text);
        
        divChangePassword.Visible = false;

        bool AreTheyActivated = WdpaLoginService1.AreTheyActivated(strUsrEmail);

        if (AreTheyActivated)
        {
            divSuccessPasswordChange.Visible = true;
        }
        else
        {
            divAccountNotActivated.Visible = true;
        }
    }
}